Suppress section edit links with action=render
authorMaxSem <maxsem.wiki@gmail.com>
Tue, 11 Mar 2014 20:00:02 +0000 (20:00 +0000)
committerJdlrobson <jrobson@wikimedia.org>
Wed, 12 Mar 2014 18:27:01 +0000 (18:27 +0000)
action=render is often used to pull the rendered HTML of an article
for inclusion in a different context. More often than not, the edit
links are not desired in that context.

This reverts commit a04b5d5dcb1cef9cff45170b3eee6651337678be
and redoes Iab02cbd42f2f93f0f5264a74691ae1b84f296f12.

Bug: 19415
Change-Id: I26213653c017c2e19a6f6799f3ea0676ff8524d1

RELEASE-NOTES-1.23
includes/Article.php
includes/OutputPage.php

index fb12acd..37fe9f1 100644 (file)
@@ -128,6 +128,10 @@ production.
   when the email address is already confirmed. Also, consistently use
   "confirmed", rather than "authenticated", when messaging whether or not the
   user has confirmed an email address.
   when the email address is already confirmed. Also, consistently use
   "confirmed", rather than "authenticated", when messaging whether or not the
   user has confirmed an email address.
+* (bug 19415) action=render no longer shows section edit links. This affects
+  behavior of several other features where (bogus) section edit links will
+  disappear, such as file description pages loaded via $wgUseInstantCommons or
+  pages transcluded cross-wiki via $wgEnableScaryTranscluding.
 * (bug 56912) Show correct link color on cached result of Special:DeadendPages.
 * Classes TitleListDependency and TitleDependency have been removed, as they
   have been found unused in core and extensions for a long time.
 * (bug 56912) Show correct link color on cached result of Special:DeadendPages.
 * Classes TitleListDependency and TitleDependency have been removed, as they
   have been found unused in core and extensions for a long time.
index b132ca9..28a5380 100644 (file)
@@ -1480,6 +1480,7 @@ class Article implements Page {
         */
        public function render() {
                $this->getContext()->getOutput()->setArticleBodyOnly( true );
         */
        public function render() {
                $this->getContext()->getOutput()->setArticleBodyOnly( true );
+               $this->getContext()->getOutput()->enableSectionEditLinks( false );
                $this->view();
        }
 
                $this->view();
        }
 
index efcd838..68958b6 100644 (file)
@@ -257,10 +257,15 @@ class OutputPage extends ContextSource {
        private $mTarget = null;
 
        /**
        private $mTarget = null;
 
        /**
-        * @var bool: Whether output should contain table of contents
+        * @var bool: Whether parser output should contain table of contents
         */
        private $mEnableTOC = true;
 
         */
        private $mEnableTOC = true;
 
+       /**
+        * @var bool: Whether parser output should contain section edit links
+        */
+       private $mEnableSectionEditLinks = true;
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -1613,6 +1618,11 @@ class OutputPage extends ContextSource {
        function addParserOutput( &$parserOutput ) {
                $this->addParserOutputNoText( $parserOutput );
                $parserOutput->setTOCEnabled( $this->mEnableTOC );
        function addParserOutput( &$parserOutput ) {
                $this->addParserOutputNoText( $parserOutput );
                $parserOutput->setTOCEnabled( $this->mEnableTOC );
+
+               // Touch section edit links only if not previously disabled
+               if ( $parserOutput->getEditSectionTokens() ) {
+                       $parserOutput->setEditSectionTokens( $this->mEnableSectionEditLinks );
+               }
                $text = $parserOutput->getText();
                wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
                $this->addHTML( $text );
                $text = $parserOutput->getText();
                wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
                $this->addHTML( $text );
@@ -3691,4 +3701,21 @@ $templates
        public function isTOCEnabled() {
                return $this->mEnableTOC;
        }
        public function isTOCEnabled() {
                return $this->mEnableTOC;
        }
+
+       /**
+        * Enables/disables section edit links, doesn't override __NOEDITSECTION__
+        * @param bool $flag
+        * @since 1.23
+        */
+       public function enableSectionEditLinks( $flag = true ) {
+               $this->mEnableSectionEditLinks = $flag;
+       }
+
+       /**
+        * @return bool
+        * @since 1.23
+        */
+       public function sectionEditLinksEnabled() {
+               return $this->mEnableSectionEditLinks;
+       }
 }
 }